<?php

namespace Modules\Web\Http\Controllers;

use Illuminate\Http\Request;
use Modules\Web\Service\GoodsOrderService;
use HiCommon\Service\StatisticsService;

class GoodsOrderController extends BaseController
{

    /*************************************积分订单和订单处理************************************/
    /**
     * 积分商品订单列表
     * yang 2019 11 04
     */
    public function get_mall_order_list(Request $request)
    {
        $arrInput = $request->all();
        $arr_list = GoodsOrderService::get_mall_order_list((array)$arrInput);
        return response_json($arr_list);
    }

    /**
     * 积分商品订单详情
     * yang 2019 11 04
     */
    public function get_mall_order_info(Request $request)
    {
        $oid = $request->get('id');
        $info = GoodsOrderService::get_mall_order_info((int)$oid);
        return response_json($info);
    }

    /**
     * 确认发货
     * yang 2019 11 04
     */
    public function send_mall_goods(Request $request)
    {
        $arrInput = $request->all();
        $res = GoodsOrderService::send_mall_goods((array)$arrInput);
        return response_json($res);
    }



    /**********************************普通订单及处理************************************/
    /**
     * 普通商品订单列表
     * 2019 11 05
     */
    public function get_store_order_list(Request $request)
    {
        $data = $request->all();

        $res = GoodsOrderService::get_store_order_list($data);

        return response_json($res);
    }

    /**
     * 获取普通商品订单详情
     * 2019 11 08
     */
    public function get_store_order_info(Request $request)
    {
        $oid = $request->get('id');

        $res = GoodsOrderService::get_store_order_info((int)$oid);
        return response_json($res);
    }

    /**
     * 订单操作
     * 2019 11 09
     */
    public function store_order_operation(Request $request)
    {
        $data = $request->all();

        shiwu_start();
        $res = GoodsOrderService::store_order_operation((array)$data);
        shiwu_end($res);

        return response_json($res);
    }

    /**
     * 门店中心订单统计
     * 2019 11 22
     */
    public function order_statistics(Request $request)
    {
//        $data = $request->all();
//        $data['shop_id'] = get_web_shop_id();//门店id

        $data = $request->all();
        $arr_admin = web_user();
        $n_shop_id = intval($arr_admin->shop_id);
        $res = StatisticsService::statistics($n_shop_id, $data);

        return response_json($res);
    }


    /**
     * 普通商品订单售后（申请退货退款列表）
     * 2019 11 05
     */
    public function store_order_sale_list(Request $request)
    {
        $data = $request->all();

        $res = GoodsOrderService::store_order_sale_list($data);

        return response_json($res);
    }

    /**
     * 普通商品售后订单详情
     * 2019 11 05
     */
    public function store_order_sale_info(Request $request)
    {
        $refund_id = $request->input('refund_id');

        $res = GoodsOrderService::store_order_sale_info((int)$refund_id);

        return response_json($res);
    }

    /**
     * 普通商品售后操作
     * 2020-04-13
     */
    public function store_order_sale_handle(Request $request)
    {
        $data = $request->all();

        $res = GoodsOrderService::store_order_sale_handle($data);

        return response_json($res);
    }

}